package index

import (
	"gin-project-01/gin-step02/gin11-file-upload-example/controllers"
	"gin-project-01/gin-step02/gin11-file-upload-example/models"
	"github.com/gin-gonic/gin"
	"math/rand"
	"net/http"
	"time"
)

type IndexController struct {
	controllers.BaseController //继承 controllers.BaseController
}

func (base IndexController) Index(c *gin.Context) {
	c.HTML(http.StatusOK, "demo11/index.html", gin.H{
		"title": "这是一个大大的Index标题",                         //长度27
		"time":  time.Now().Format("2006-01-02 15:04:05"), //传入到对应的html页面 {{ .time }}
		"week":  time.Now().Weekday().String(),            //传入到对应的html页面 {{ .week }}
		"date":  time.Now().Unix(),
		"num":   rand.Intn(100),
		"day":   models.GetDay(),
	})
}

// File
//
//	@Description: 跳转到file.html
//	@receiver base
//	@param c
func (base IndexController) File(c *gin.Context) {
	c.HTML(http.StatusOK, "demo11/file.html", gin.H{})
}
